<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Gloze: Ordered Content</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />



</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">Gloze
   &#160;<span id="projectnumber">1.01-beta2</span>
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li class="current"><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="namespaces.html"><span>Packages</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
    </ul>
  </div>
</div>
<div class="header">
  <div class="headertitle">
<div class="title">Ordered Content </div>  </div>
</div>
<div class="contents">
<div class="textblock"><p>An XML document has a tree structure where the children of each element are lexically ordered. Sometimes this ordering is significant, sometimes it is not. <a class="el" href="classcom_1_1hp_1_1gloze_1_1_gloze.html">Gloze</a> is designed from the point of view of retaining sufficient information to reconstruct the original document from the RDF, making it possible to round-trip from XML to RDF and back again. This doesn't mean recording the order in all cases. In many cases the XML schema contains enough ordering information to reconstruct the original sequence. Ambiguity is created by multiple occurrences of the same element, by mixed content, or by the appearance of the xs:any wild-card. Sequences of singly occurring xs:sequence are entirely unambigous, as are choices where only one of the choices can occur (so long as this occurs once). The compositor 'all', where all orderings are valid typically require sequencing (unless in the degenerate case where they only have a single element). The ordering of attributes is not significant.</p>
<p>All the examples in this section were generated with order=seq (-Dgloze.order=seq).</p>
<p>The following schema describes an unambiguous sequence containing an unambiguous choice.</p>
<div class="fragment"><pre class="fragment">&lt;?xml version=<span class="stringliteral">&quot;1.0&quot;</span> encoding=<span class="stringliteral">&quot;UTF-8&quot;</span>?&gt;
&lt;xs:schema xmlns:xs=<span class="stringliteral">&quot;http://www.w3.org/2001/XMLSchema&quot;</span> 
        targetNamespace=<span class="stringliteral">&quot;http://example.org/&quot;</span> xmlns=<span class="stringliteral">&quot;http://example.org/&quot;</span> elementFormDefault=<span class="stringliteral">&quot;qualified&quot;</span>&gt;

        &lt;xs:element name=<span class="stringliteral">&quot;foobar&quot;</span>&gt;
                &lt;xs:complexType&gt;
                        &lt;xs:sequence&gt;
                                &lt;xs:element name=<span class="stringliteral">&quot;foo&quot;</span> type=<span class="stringliteral">&quot;xs:string&quot;</span> minOccurs=<span class="stringliteral">&quot;0&quot;</span> /&gt;
                                &lt;xs:choice&gt;
                                        &lt;xs:element name=<span class="stringliteral">&quot;bar&quot;</span> type=<span class="stringliteral">&quot;xs:string&quot;</span>/&gt;
                                        &lt;xs:element name=<span class="stringliteral">&quot;baz&quot;</span> type=<span class="stringliteral">&quot;xs:string&quot;</span>/&gt;
                                &lt;/xs:choice&gt;
                        &lt;/xs:sequence&gt;
                &lt;/xs:complexType&gt;
        &lt;/xs:element&gt;

&lt;/xs:schema&gt;
</pre></div><p>The XML below requires no additional ordering information.</p>
<div class="fragment"><pre class="fragment">&lt;?xml version=<span class="stringliteral">&quot;1.0&quot;</span> encoding=<span class="stringliteral">&quot;UTF-8&quot;</span>?&gt;
&lt;foobar xmlns=<span class="stringliteral">&quot;http://example.org/&quot;</span>&gt;
        &lt;foo&gt;foobar&lt;/foo&gt;
        &lt;bar&gt;foobar&lt;/bar&gt;
&lt;/foobar&gt;

</pre></div> <div class="fragment"><pre class="fragment">@prefix ns2:     &lt;http:<span class="comment">//example.org/def/&gt; .</span>
@prefix ns1:     &lt;http:<span class="comment">//example.org/&gt; .</span>
@prefix xs_:     &lt;http:<span class="comment">//www.w3.org/2001/XMLSchema#&gt; .</span>
@prefix rdf:     &lt;http:<span class="comment">//www.w3.org/1999/02/22-rdf-syntax-ns#&gt; .</span>
@prefix xs:      &lt;http:<span class="comment">//www.w3.org/2001/XMLSchema&gt; .</span>

&lt;http:<span class="comment">//example.org/ordering.xml&gt;</span>
      ns1:foobar
              [ ns1:bar <span class="stringliteral">&quot;foobar&quot;</span>^^xs_:string ;
                ns1:foo <span class="stringliteral">&quot;foobar&quot;</span>^^xs_:string
              ] .
</pre></div><p>Where there is ambiguity in the schema for a given element content this is captured as an RDF sequence. We need to record the order in which particular statements appear. This is achieved by reifying the statement, giving us an object that can be added to an rdf:Seq.</p>
<p>The schema below permits multiple occurrences of the element 'bar', so ordering information needs to be recorded if it is significant.</p>
<div class="fragment"><pre class="fragment">&lt;?xml version=<span class="stringliteral">&quot;1.0&quot;</span> encoding=<span class="stringliteral">&quot;UTF-8&quot;</span>?&gt;
&lt;xs:schema xmlns:xs=<span class="stringliteral">&quot;http://www.w3.org/2001/XMLSchema&quot;</span> 
        targetNamespace=<span class="stringliteral">&quot;http://example.org/&quot;</span> xmlns=<span class="stringliteral">&quot;http://example.org/&quot;</span> elementFormDefault=<span class="stringliteral">&quot;qualified&quot;</span>&gt;

        &lt;xs:element name=<span class="stringliteral">&quot;foobar&quot;</span>&gt;
                &lt;xs:complexType&gt;
                        &lt;xs:sequence&gt;
                                &lt;xs:element name=<span class="stringliteral">&quot;foo&quot;</span> type=<span class="stringliteral">&quot;xs:string&quot;</span>/&gt;
                                &lt;xs:element name=<span class="stringliteral">&quot;bar&quot;</span> type=<span class="stringliteral">&quot;xs:string&quot;</span> maxOccurs=<span class="stringliteral">&quot;unbounded&quot;</span>/&gt;
                        &lt;/xs:sequence&gt;
                &lt;/xs:complexType&gt;
        &lt;/xs:element&gt;

&lt;/xs:schema&gt;
</pre></div> <div class="fragment"><pre class="fragment">&lt;?xml version=<span class="stringliteral">&quot;1.0&quot;</span> encoding=<span class="stringliteral">&quot;UTF-8&quot;</span>?&gt;
&lt;foobar xmlns=<span class="stringliteral">&quot;http://example.org/&quot;</span>&gt;
        &lt;foo&gt;foobar&lt;/foo&gt;
        &lt;bar&gt;foobar&lt;/bar&gt;
        &lt;bar&gt;foobar&lt;/bar&gt;
&lt;/foobar&gt;

</pre></div><p>The RDF mapping shows how ordering information is recorded alongside the standard RDF mapping. The standard mapping involves adding the property 'foo' with value "foobar". The subject of this statement is also an RDF sequence, and the first member of this sequence is the reification with rdf:predicate 'foo' and rdf:object "foobar". The two occurrences of 'bar'with identical values, "foobar" result in the assertion of a single property/value. Despite this, two reified statements are added to the sequence, one for each occurrence.</p>
<div class="fragment"><pre class="fragment">@prefix ns2:     &lt;http:<span class="comment">//example.org/def/&gt; .</span>
@prefix ns1:     &lt;http:<span class="comment">//example.org/&gt; .</span>
@prefix xs_:     &lt;http:<span class="comment">//www.w3.org/2001/XMLSchema#&gt; .</span>
@prefix rdf:     &lt;http:<span class="comment">//www.w3.org/1999/02/22-rdf-syntax-ns#&gt; .</span>
@prefix xs:      &lt;http:<span class="comment">//www.w3.org/2001/XMLSchema&gt; .</span>

_:b1  a       rdf:Seq ;
      rdf:_1  [ a       rdf:Statement ;
                rdf:<span class="keywordtype">object</span> <span class="stringliteral">&quot;foobar&quot;</span>^^xs_:string ;
                rdf:predicate ns1:foo ;
                rdf:subject _:b1
              ] ;
      rdf:_2  [ a       rdf:Statement ;
                rdf:<span class="keywordtype">object</span> <span class="stringliteral">&quot;foobar&quot;</span>^^xs_:string ;
                rdf:predicate ns1:bar ;
                rdf:subject _:b1
              ] ;
      rdf:_3  [ a       rdf:Statement ;
                rdf:<span class="keywordtype">object</span> <span class="stringliteral">&quot;foobar&quot;</span>^^xs_:string ;
                rdf:predicate ns1:bar ;
                rdf:subject _:b1
              ] ;
      ns1:bar <span class="stringliteral">&quot;foobar&quot;</span>^^xs_:string ;
      ns1:foo <span class="stringliteral">&quot;foobar&quot;</span>^^xs_:<span class="keywordtype">string</span> .

&lt;http:<span class="comment">//example.org/ordering1.xml&gt;</span>
      ns1:foobar _:b1 .
</pre></div><p>Ordering is transparent from an ontological perspective. One of the design goals was to allow users of the RDF mapping to ignore the sequence if it is not relevant. Ordering is treated as a data-structuring issue rather than an ontological one. The addition of a property to a resource is treated independently of adding it to the sequence; sequencing meta-data is overlaid on top of the existing unordered information model. </p>
</div></div>


<hr class="footer"/><address class="footer"><small>
Generated on Tue Nov 15 2011 22:13:50 for Gloze by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.7.5.1
</small></address>

</body>
</html>
